// export const leftConfig = {
//     width: this.boxW - 24,
//     height: this.boxH,
//     dY: 16,
//     direction: 'left',
//     speed: 2,
//     state: false
// }
// export const  GetAllQuery = () =>{
//   let  url = location.hash.replace("#/",""); //获取url中"?"符后的字串
//             let  theRequest = new Object();
//             if (url.indexOf("?") != -1) {
//                 let  str = url.substr(1);
//                 let strs = str.split("&");
//                 for (let  i = 0; i < strs.length; i++) {
//                     theRequest[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
//                 }
//             }
//             return theRequest;
// }
  
export const dateAdd = (date, interval, number) =>{
    let tempDate = new Date(date);
    switch (interval) {
        case "y":
            tempDate.setFullYear(tempDate.getFullYear() + number);
            return tempDate;
        case "q":
            tempDate.setMonth(tempDate.getMonth() + number * 3);
            return tempDate;
        case "m"://月
            tempDate.setMonth(tempDate.getMonth() + number);
            return tempDate;
        case "w":
            tempDate.setDate(tempDate.getDate() + number * 7);
            return tempDate;
        case "d"://天
            tempDate.setDate(tempDate.getDate() + number);
            return tempDate;
        case "h"://小时
            tempDate.setHours(tempDate.getHours() + number);
            return tempDate;
        case "mm"://分钟
            tempDate.setMinutes(tempDate.getMinutes() + number);
            return tempDate;
        case "s ":
            tempDate.setSeconds(tempDate.getSeconds() + number);
            return tempDate;
        default:
            tempDate.setDate(d.getDate() + number);
            return tempDate;
    } 
}
// 8点比较
export const compare8h = (date) =>{
    let tempDate = new Date(date);
    if(tempDate.getHours()>8){//9点
        return true;
    }else if(tempDate.getHours()<8){//7点
        return false; 
    }else {//8点

        if(tempDate.getMinutes()>0){//08:01
            return true; 
        }else{//08:00:59 之前属于昨天 08:00:56这类的
             return false; 
        }

    }
     
}

    export const  millisecondToDate = (msd) => {  
        let time = parseFloat(msd) /1000;  //秒
        if (null!= time &&""!= time) {  
            if (time >60&& time <60*60) {  //1分钟到1小时
                time = parseInt(time /60.0) +"分钟";
                // + parseInt((parseFloat(time /60.0) -     parseInt(time /60.0)) *60) +"秒";  
            }else if (time >=60*60&& time <60*60*24) {  //1小时到24小时
                time = parseInt(time /3600.0) +"小时"+ parseInt((parseFloat(time /3600.0) - parseInt(time /3600.0)) *60) +"分钟"; 
            }else {    //大于24小时
               time =  parseInt(time /(3600.0*24)) +"天"+parseInt((parseFloat(time /(3600.0*24)) - parseInt(time /(3600.0*24))) *60) +"小时"+ parseInt((parseFloat(time /3600.0) - parseInt(time /3600.0)) *60) +"分钟";
            }  
        }else{  
            time = "0 时 0 分";  
        }  
        return time;   
 }

export const addCookie = (objName,objValue,objHours) =>{ //设置cookie
    let str = objName + "=" + escape(objValue);
      if(objHours > 0){ //为时不设定过期时间，浏览器关闭时cookie自动消失
          let date = new Date();
          let ms = objHours*3600*1000*24;//1天
          date.setTime(date.getTime() + ms);
          str += "; expires=" + date.toGMTString();
     }
     document.cookie = str;
}
export const getCookies = (objName) => { //读取cookie
   let arrStr = document.cookie.split("; ");
    for(let i = 0;i < arrStr.length;i ++){
        let temp = arrStr[i].split("=");
        if(temp[0] == objName) return unescape(temp[1]);
    } 
}
export const delCookie = (name) => { //删除cookie
   let exp = new Date();
   exp.setTime(exp.getTime() - 1);
   let cval=getCookies(name);
   if(cval!=null)
   {
     document.cookie= name + "="+cval+";expires="+exp.toGMTString();
   }
}  